<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>大事件-文章列表</title>
    <link rel="stylesheet" href="/assets/lib/layui/css/layui.css" />
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        background-color: #edebeb;
        padding: 20px;
      }
      .layui-form {
        width: 400px;
      }
      .layui-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    </style>
  </head>
  <body>
    <div class="layui-card">
      <div class="layui-card-header">
        <span>文章列表管理</span>
      </div>
      <div class="layui-card-body">
        <!-- 放置筛选表单 -->
        <form class="layui-form" id="myForm" lay-filter="formData">
          <div class="layui-form-item layui-inline">
            <!-- select标签必须写上闭合 -->
            <!-- name属性表示表单中属性的名称 -->
            <select name="cate_id">
              <!-- 下拉选项不是死的 -动态获取的文章分类 -->
              <!-- <option value="分类的ID">分类的名称</option> -->
            </select>
          </div>
          <div class="layui-form-item layui-inline">
            <select name="state">
              <!-- 状态的下拉选项是死的 -->
              <!-- 因为所有状态没有这个筛选项目 把value设置为“” -->
              <option value="">所有状态</option>
              <option>已发布</option>
              <option>草稿</option>
            </select>
          </div>
          <div class="layui-form-item layui-inline">
            <button class="layui-btn" lay-submit lay-filter="formDemo">
              筛选
            </button>
          </div>
        </form>
        <!-- 放置table表格 -->
        <table class="layui-table">
          <colgroup>
            <col />
            <col width="150" />
            <col width="150" />
            <col width="150" />
            <col width="150" />
          </colgroup>
          <thead>
            <tr>
              <th>文章标题</th>
              <th>文章分类</th>
              <th>文章状态</th>
              <th>发布时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody></tbody>
        </table>
        <!-- 放置分页 -->
        <div id="myPage"></div>
      </div>
    </div>
    <!-- 定义option的模板 -->
    <script type="text/html" id="option-temp">
      <option value="">所有分类</option>
      {{each data}}
      <option value="{{$value.Id}}">{{ $value.name }}</option>
      {{/each}}
    </script>
    <!-- 定义模版引擎的模版 -->
    <script type="text/html" id="table-temp">
      {{ each data }}
      <tr>
        <td>{{ $value.title }}</td>
        <td>{{ $value.cate_name }}</td>
        <td>{{ $value.state }}</td>
        <td>{{ $value.pub_date }}</td>
        <td>
          <button
            onclick="delArt({{ $value.Id }})"
            class="layui-btn layui-btn-xs layui-btn-danger"
          >
            删除
          </button>
        </td>
      </tr>
      {{ /each }}
    </script>

    <script src="/assets/lib/layui/layui.all.js"></script>
    <script src="/assets/lib/jquery.js"></script>
    <script src="/assets/js/baseAPI.js"></script>
    <script src="/assets/lib/template-web.js"></script>
    <script src="/assets/js/article/art_list.js"></script>
  </body>
</html>
